<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use yii\widgets\Pjax;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\GkyQyhMenuSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Gky Qyh Menus';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="gky-qyh-menu-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <div class="col-lg-8">
        <?php
        $form = ActiveForm::begin([
                'action' => ['index'],
                'method' => 'get',
                'options' => ['class' => 'input-group'],
                'fieldConfig' => [
                    'template' => '<div class="col-lg-12">{input}</div>',
                ]
            ])
        ?>
        
        <?php
//        $data =app\models\GkyQyhMenu::find()->all();
//          echo $form->field($searchModel,'id')->widget(Select2::classname(), [
//          'data' => ArrayHelper::map($data, 'id', 'id'),
//          'options' => ['placeholder' => '请输入内容'],
//          'pluginOptions' => [
//                        'allowClear' => true
//                    ],
//            ]);        
            ?> 
         <?php
                $projects = app\models\GkyQyhMenu::find()->all();
                foreach ($projects as $item) {
                    $source[] = $item->id;
                }
                echo yii\jui\AutoComplete::widget([
                    'model' => $searchModel,
                    'attribute' => 'id',
                    'options'=>['style'=>'margin-left:10px'],
                    'clientOptions' => [
                        'source' => $source,
                    ],
                ]);
                ?>       
    </div>
    
    <div class="col-lg-4">
       <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> 
       <?= Html::a('Create', ['create'], ['class' => 'btn btn-primary']) ?>
       <?= Html::a('生成菜单', ['set-menu','id'=>$app->qid,'agentid'=>$app->agentid], ['class' => 'btn btn-primary']) ?>
    </div>
    
    <?php ActiveForm::end(); ?>    
    <?php Pjax::begin(); ?>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'app_id',
            'pid',
            'name',
            'type',
            // 'key',
            // 'url:url',
            // 'sort',
            // 'isSet',

            [
                'class' => 'yii\grid\ActionColumn',
                'template' => '{view} {update} {delete}',
                'buttons' => [
                    //view button
                    'view' => function ($url) {
                        return Html::a('<span class="fa fa-search"></span>查看', $url, [
                                    'title' => Yii::t('app', 'View'),
                                    'class' => 'btn btn-primary btn-xs',
                        ]);
                    },
                            //update button
                            'update' => function ($url) {
                        return Html::a('<span class="fa fa-search"></span>更新', $url, [
                                    'title' => Yii::t('app', 'Update'),
                                    'class' => 'btn btn-primary btn-xs',
                        ]);
                    },
                            //update button
                            'delete' => function ($url) {
                        return Html::a('<span class="fa fa-search"></span>删除', $url, [
                                    'title' => Yii::t('app', 'Delete'),
                                    'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
                                    'data-method' => 'post',
                                    'data-pjax' => '0',
                                    'class' => 'btn btn-primary btn-xs',
                        ]);
                    },
                        ],
            ],
        ],
    ]); ?>
<?php Pjax::end(); ?>
</div>
